// 主界面
;
define(function(require, exports, module) {
	'use strict';
	var util = require("util");
	var base = require("base");
	var router = require("../hash/pageRouter");
	var dialog = require("dialog");
	var validate = require("validate");
	var css_detail_info = require("./exceptionDetailInfo.css");
	var css_detail_info1 = require("./exceptionManage.css");
	var databind = require("databind");
	var constant = require("constant");
	var abnormalId;
	var tools = require("tools");
	var html_exception_surveys = require("./html_exception_surveys.html");
	var html_exception_blames = require("./html_exception_blames.html");
	var html_exception_casualties = require("./html_exception_casualties.html");
	var html_exception_correctives = require("./html_exception_correctives.html");
	var html_exception_equipments = require("./html_exception_equipments.html");
	var html_exception_expenses = require("./html_exception_expenses.html");
	var html_exchange_abnormal = require("./html_exchange_abnormal.html");
	var html_adjust_abnormal = require("./html_adjust_abnormal.html");
	var html_add_expenseName = require("./html_add_expenseName.html");
	var html_normal_abnormal_inventory = require("./html_normal_abnormal_inventory.html");
	var html_return_abnormal_inventory = require("./html_return_abnormal_inventory.html");
	var html_handle_abnormal_inventory = require("./html_handle_abnormal_inventory.html");
	var html_insurance_list = require("./html_insurance_list.html");
	var html_create_claim = require("./html_create_claim.html");
	var html_riskDetailInfo = require("./html_riskDetailInfo.html");
	var handleState;
	var claimId;
	var storage = window.sessionStorage;
	var pageIndex = 1,
		pageSize = 10,
		totalPageCount = 1,
		totalRecordCount = 0; //分页初始化
	var commonSelectorList; //系统参数
	var init = function(page) {
		if (page.params != null) {
			abnormalId = page.params.abnormalId;
		} else {
			abnormalId = storage.getItem("abnormalId");
		}
		inquireAbnormalDetail();
		initEvent();
		router.init();
	};
	var initEvent = function() {

		//若未登录，则返回登陆页面
		if (base.getData("sid") == null || base.getData("sid") == "" || base.getData("sid") == undefined) {
			top.location.href = "../login/login.html";
		}

		//添加风险信息
		$(".addRisk").on("click", function() {
			$("#popdialog").html(html_riskDetailInfo);
			tools.requireInput($("#popdialog1"));
			dialog.showDialog($("#create_risk_dialog"));
			tools.inquireCommonSelectorList(12, $("#create_risk_dialog .riskType"));
			tools.inquireCommonSelectorList(13, $("#create_risk_dialog .strategy"));
			tools.inquireCommonSelectorList(14, $("#create_risk_dialog .riskGrade"));
			databind.fillForm($("#create_risk_dialog"), {
				abnormalId: abnormalId
			});
			$("#create_risk_dialog .sure_yes").unbind("click").click(function() {
				databind.submitDom($("#create_risk_dialog"), function(data) {
					if (data.status == 200) {
						base.alert(1, "添加风险信息成功");
						dialog.hideDialog($("#create_risk_dialog"));
						router.route("exception/exceptionDetailInfo.html?abnormalId="+abnormalId);
					} else {
						base.alert(3, data.message);
					}
				});
			});

			//附件添加
			$("#create_risk_dialog").on("change", "#claimMaterial", function() {
				uploadFile($("#claimMaterial"), $(".claimMaterial"), $("#riskFileUuid"), "claimMaterial");
			});
		});

		$("#exceptionDetailInfo").on("click", ".exceptionTablesNavItem", function() {
			if (handleState != 3) {
				$(".addException").addClass("none");
			} else {
				if ($(this).attr("exceptionBody") == "exceptionBody6") {
					$(".addException").addClass("none");
				} else {
					$(".addException").removeClass("none");
				}
			}
			$(this).parent().find("a").removeClass("exceptionTablesNav-active");
			$(this).addClass("exceptionTablesNav-active");
			$(".exceptionBody").addClass("none");
			$("." + $(this).attr("exceptionBody")).removeClass("none");
		});

		$("#exceptionDetailInfo").on("click", "#createClaim", function() {
			$("#popdialog").html(html_insurance_list);
			dialog.showDialog($("#insurance_list_dialog"));
			var oData = {
				pageIndex: pageIndex,
				pageSize: pageSize,
				totalPageCount: totalPageCount,
				totalRecordCount: totalRecordCount,
				insuranceState: 2,
				financeId: $("#exceptionDetailInfo .financeId").val()
			};
			tools.loadList("inquireInsurancePageList.json", $("#htmlInsuranceListTable"), $("#htmlInsuranceListTpl"), oData, function() {});
			var insuranceId;

			if (1 == $("#insurance_list_dialog tr").length) {
				$("#insurance_list_dialog .dialog_content").html("<div style='text-align:center; margin-top:50px'>暂时无可选保险</div>");
				$("#insurance_list_dialog").on("click", ".sure_no", function() {
					dialog.hideDialog($("#insurance_list_dialog"));
				});

				$("#insurance_list_dialog").on("click", ".sure_yes", function() {
					dialog.hideDialog($("#insurance_list_dialog"));
				});
			} else {
				$("#insurance_list_dialog").on("click", ".sure_yes", function() {
					insuranceId = $("#insurance_list_dialog .insuranceId:checked").val();

					if (insuranceId == null) {
						base.alert(2, "请选择保险！");
					} else {
						dialog.hideDialog($("#insurance_list_dialog"));
						$("#popdialog").html(html_create_claim);
						dialog.showDialog($("#create_claim_dialog"));
						tools.loadList("inquireInsuranceDetail.json", $("#createClaimBody"), $("#createClaimTpl"), {
							insuranceId: insuranceId
						}, function() {
							databind.fillForm($("#create_claim_dialog"), {
								abnormalId: abnormalId,
								insuranceId: insuranceId,
								abnormalNumber: $(".abnormalNumber").val()
							});
							tools.requireInput($("#create_claim_dialog"));
							$("#create_claim_dialog").on("click", ".sure_no", function() {
								dialog.hideDialog($("#create_claim_dialog"));
							});

							$("#create_claim_dialog").on("click", ".sure_yes", function() {
								databind.submitDom($("#create_claim_dialog"), function() {
									base.alert(1, "创建索赔成功！");
									dialog.hideDialog($("#create_claim_dialog"));
								});
							});

							$("#create_claim_dialog").on("change", ".claimAmount", function() {
								var sum = 0;
								$.each($(".claimAmount"), function() {
									sum += $(this).val() * 1;
								});
								$(".claimAmounts").val(sum);
							});

							$("#create_claim_dialog").on("change", ".compensate", function() {
								var sum = 0;
								$.each($(".compensate"), function() {
									sum += $(this).val() * 1;
								});
								$(".compensates").val(sum);
							});
						});
					}
				});

				$("#insurance_list_dialog").on("click", ".sure_no", function() {
					dialog.hideDialog($("#insurance_list_dialog"));
				});
			}
		});

//		$("#exceptionDetailInfo").on("mouseover", ".exceptionInventoryDetail", function() {
//			var $this = $(this).parent().find(".inventoryNavList");
//			if (handleState == 3) {
//				$(this).parent().find(".inventoryNavList").css("display", "block");
//				setTimeout(function() {
//					$this.css("display", "none");
//				}, 2000);
//			} else {
//				var $this = $(this).parent().find(".inventoryNavList");
//			}
//		});

		//正常监管
		$("#exceptionDetailInfo").on("click", ".normalAbnormal", function() {
			var aid = $(this).parents("tr").attr("abnormalinventoryid");
			$("#popdialog").html(html_normal_abnormal_inventory);
			dialog.showDialog($("#normal_abnormal_inventory_dialog"));
			tools.requireInput($("#normal_abnormal_inventory_dialog"));
			tools.inquireCommonSelectorList(10, $("#normal_abnormal_inventory_dialog .reson"));
			databind.fillForm("#normal_abnormal_inventory_dialog", {
				"abnormalInventoryId": aid
			});
			$("#normal_abnormal_inventory_dialog .sure_no").unbind("click").click(function() {
				dialog.hideDialog($("#normal_abnormal_inventory_dialog"));
			});

			$("#normal_abnormal_inventory_dialog .sure_yes").unbind("click").click(function() {
				databind.submitDom($("#normal_abnormal_inventory_dialog"), function() {
					base.alert(1, "监管成功！");
					dialog.hideDialog($("#normal_abnormal_inventory_dialog"));
					router.route("exception/exceptionDetailInfo.html?abnormalId=" + abnormalId);
				});
			});
		});

		//退货处理
		$("#exceptionDetailInfo").on("click", ".returnAbnormal", function() {
			var aid = $(this).parents("tr").attr("abnormalinventoryid");
			$("#popdialog").html(html_return_abnormal_inventory);
			dialog.showDialog($("#return_abnormal_inventory_dialog"));
			tools.requireInput($("#return_abnormal_inventory_dialog"));
			tools.inquireCommonSelectorList(10, $("#return_abnormal_inventory_dialog .reson"));
			databind.fillForm("#return_abnormal_inventory_dialog", {
				"abnormalInventoryId": aid
			});
			$("#return_abnormal_inventory_dialog .sure_no").unbind("click").click(function() {
				dialog.hideDialog($("#return_abnormal_inventory_dialog"));
			});

			$("#return_abnormal_inventory_dialog .sure_yes").unbind("click").click(function() {
				databind.submitDom($("#return_abnormal_inventory_dialog"), function() {
					base.alert(1, "退货成功！");
					dialog.hideDialog($("#return_abnormal_inventory_dialog"));
					router.route("exception/exceptionDetailInfo.html?abnormalId=" + abnormalId);
				});
			});
		});

		//换箱
		$("#exceptionDetailInfo").on("click", ".exchangeAbnormal", function() {
			$("#popdialog").html(html_exchange_abnormal);
			var aid = $(this).parents("tr").attr("abnormalinventoryid");
			var caseNumber = $(this).parents("tr").attr("caseNumber");
			dialog.showDialog($("#exchange_abnormal_dialog"));
			databind.fillForm($("#exchange_abnormal_dialog"), {
				"abnormalInventoryId": aid
			});
			tools.requireInput($("#exchange_abnormal_dialog"));
			inquireAbnormalDetail1();
			$("#exchange_abnormal_dialog .sure_no").unbind("click").click(function() {
				dialog.hideDialog($("#exchange_abnormal_dialog"));
			});
			$("#exchange_abnormal_dialog .sure_yes").unbind("click").click(function() {
				if ($("#exchange_abnormal_dialog .targetCaseNumber").val() == caseNumber) {
					base.alert(3, "调换箱号不能与原箱号相同！");
				} else {
					databind.submitDom($("#exchange_abnormal_dialog"), function() {
						base.alert(1, "换箱成功！");
						dialog.hideDialog($("#exchange_abnormal_dialog"));
						router.route("exception/exceptionDetailInfo.html?abnormalId=" + abnormalId);
					});
				}
			});
		});

		//额度处理
		$("#exceptionDetailInfo").on("click", ".adjustAbnormal", function() {
			$("#popdialog").html(html_adjust_abnormal);
			var aid = $(this).parents("tr").attr("abnormalinventoryid");
			dialog.showDialog($("#adjust_abnormal_dialog"));
			databind.fillForm($("#adjust_abnormal_dialog"), {
				"abnormalInventoryId": aid
			});
			tools.requireInput($("#adjust_abnormal_dialog"));
			tools.inquireCommonSelectorList(10, $("#adjust_abnormal_dialog .reson"));
			inquireAbnormalDetail1();
			$("#adjust_abnormal_dialog .sure_no").unbind("click").click(function() {
				dialog.hideDialog($("#adjust_abnormal_dialog"));
			});
			$("#adjust_abnormal_dialog .sure_yes").unbind("click").click(function() {
				databind.submitDom($("#adjust_abnormal_dialog"), function() {
					base.alert(1, "额度调整成功！");
					dialog.hideDialog($("#adjust_abnormal_dialog"));
					router.route("exception/exceptionDetailInfo.html?abnormalId=" + abnormalId);
				});
			});
		});
		
		//处置
		$("#exceptionDetailInfo").on("click", ".handleAbnormal", function() {
			$("#popdialog").html(html_handle_abnormal_inventory);
			var aid = $(this).parents("tr").attr("abnormalinventoryid");
			dialog.showDialog($("#handle_abnormal_inventory_dialog"));
			databind.fillForm($("#handle_abnormal_inventory_dialog"), {
				"abnormalInventsoryId": aid
			});
			tools.requireInput($("#handle_abnormal_inventory_dialog"));
			tools.inquireCommonSelectorList(10, $("#handle_abnormal_inventory_dialog .reson"));
			$("#handle_abnormal_inventory_dialog .sure_no").unbind("click").click(function() {
				dialog.hideDialog($("#handle_abnormal_inventory_dialog"));
			});
			$("#handle_abnormal_inventory_dialog .sure_yes").unbind("click").click(function() {
				databind.submitDom($("#handle_abnormal_inventory_dialog"), function() {
					base.alert(1, "处置成功！");
					dialog.hideDialog($("#handle_abnormal_inventory_dialog"));
					router.route("exception/exceptionDetailInfo.html?abnormalId=" + abnormalId);
				});
			});
		});

		//箱货详情		
		$("#exceptionDetailInfo").on("click", ".addException", function() {
			var exceptionBody = $(".exceptionTablesNav-active").attr("exceptionBody");
			if (exceptionBody == "exceptionBody1") {
				$("#popdialog").html(html_exception_surveys);
				tools.requireInput($("#popdialog"));
				dialog.showDialog($("#exception_surveys_dialog"));
				$("textarea").parent().css("text-align", "right");
				databind.fillForm($("#exception_surveys_dialog"), {
					"abnormalId": abnormalId
				});
				$("#exception_surveys_dialog .sure_no").unbind("click").click(function() {
					dialog.hideDialog($("#exception_surveys_dialog"));
				});
				$("#exception_surveys_dialog .sure_yes").unbind("click").click(function() {
					databind.submitDom($("#exception_surveys_dialog"), function() {
						base.alert(1, "异常调查添加成功！");
						dialog.hideDialog($("#exception_surveys_dialog"));
						router.route("exception/exceptionDetailInfo.html?abnormalId=" + abnormalId);
					});
				});
			} else if (exceptionBody == "exceptionBody2") {
				$("#popdialog").html(html_exception_blames);
				tools.requireInput($("#popdialog"));
				dialog.showDialog($("#exception_blames_dialog"));
				$("textarea").parent().css("text-align", "right");
				databind.fillForm($("#exception_blames_dialog"), {
					"abnormalId": abnormalId
				});
				$("#exception_blames_dialog .handleMode").on("change", function() {
					if ($(this).val() == "13") {
						$("#exception_blames_dialog .fine input").attr({
							"isNULL": "1",
							"codeName": "罚款金额"
						});
					} else {
						$("#exception_blames_dialog .fine input").removeAttr("isNULL");
						$("#exception_blames_dialog .fine input").removeAttr("codeName");
						$("#exception_blames_dialog .fine font").remove();
					}
					tools.requireInput($("#exception_blames_dialog .fine"));
				});

				$("#exception_blames_dialog").on("change", ".mold", function() {
					judgeMold($(this).val(), $("#company"), $("#companyId"));
				});

				$("#exception_blames_dialog .sure_no").unbind("click").click(function() {
					dialog.hideDialog($("#exception_blames_dialog"));
				});
				$("#exception_blames_dialog .sure_yes").unbind("click").click(function() {
					databind.submitDom($("#exception_blames_dialog"), function() {
						base.alert(1, "责任人处理添加成功！");
						dialog.hideDialog($("#exception_blames_dialog"));
						router.route("exception/exceptionDetailInfo.html?abnormalId=" + abnormalId);
					});
				});
			} else if (exceptionBody == "exceptionBody3") {
				$("#popdialog").html(html_exception_correctives);
				tools.requireInput($("#popdialog"));
				dialog.showDialog($("#exception_correctives_dialog"));
				$("textarea").parent().css("text-align", "right");
				databind.fillForm($("#exception_correctives_dialog"), {
					"abnormalId": abnormalId
				});

				$("#exception_correctives_dialog .sure_no").unbind("click").click(function() {
					dialog.hideDialog($("#exception_correctives_dialog"));
				});
				$("#exception_correctives_dialog .sure_yes").unbind("click").click(function() {
					databind.submitDom($("#exception_correctives_dialog"), function() {
						base.alert(1, "整改总结添加成功！");
						dialog.hideDialog($("#exception_correctives_dialog"));
						router.route("exception/exceptionDetailInfo.html?abnormalId=" + abnormalId);
					});
				});
			} else if (exceptionBody == "exceptionBody4") {
				$("#popdialog").html(html_exception_casualties);
				tools.requireInput($("#popdialog"));
				dialog.showDialog($("#exception_casualties_dialog"));
				$("textarea").parent().css("text-align", "right");
				databind.fillForm($("#exception_casualties_dialog"), {
					"abnormalId": abnormalId
				});

				$("#exception_casualties_dialog .indemnity").on("change", function() {
					if ($(this).val() == true) {
						$("#exception_casualties_dialog .damages input").attr({
							"isNULL": "1",
							"codeName": "赔偿金额"
						});
					} else {
						$("#exception_casualties_dialog .damages input").removeAttr("isNULL");
						$("#exception_casualties_dialog .damages input").removeAttr("codeName");
						$("#exception_casualties_dialog .damages font").remove();
					}
					tools.requireInput($("#exception_casualties_dialog .damages"));
				});

				$("#exception_casualties_dialog").on("change", ".mold", function() {
					judgeMold($(this).val(), $("#company"), $("#companyId"));
				});

				$("#exception_casualties_dialog .sure_no").unbind("click").click(function() {
					dialog.hideDialog($("#exception_casualties_dialog"));
				});
				$("#exception_casualties_dialog .sure_yes").unbind("click").click(function() {
					databind.submitDom($("#exception_casualties_dialog"), function() {
						base.alert(1, "人员伤亡添加成功！");
						dialog.hideDialog($("#exception_casualties_dialog"));
						router.route("exception/exceptionDetailInfo.html?abnormalId=" + abnormalId);
					});
				});
			} else if (exceptionBody == "exceptionBody5") {
				$("#popdialog").html(html_exception_equipments);
				tools.requireInput($("#popdialog"));
				dialog.showDialog($("#exception_equipments_dialog"));
				$("textarea").parent().css("text-align", "right");
				databind.fillForm($("#exception_equipments_dialog"), {
					"abnormalId": abnormalId
				});

				$("#exception_equipments_dialog .indemnity").on("change", function() {
					if ($(this).val() == true) {
						$("#exception_equipments_dialog .abnormalAmount input").attr({
							"isNULL": "1",
							"codeName": "赔偿金额"
						});
					} else {
						$("#exception_equipments_dialog .abnormalAmount input").removeAttr("isNULL");
						$("#exception_equipments_dialog .abnormalAmount input").removeAttr("codeName");
						$("#exception_equipments_dialog .abnormalAmount font").remove();
					}
					tools.requireInput($("#exception_equipments_dialog .abnormalAmount"));
				});

				$("#exception_equipments_dialog").on("change", ".mold", function() {
					judgeMold($(this).val(), $("#company"), $("#companyId"));
				});

				$("#exception_equipments_dialog .sure_no").unbind("click").click(function() {
					dialog.hideDialog($("#exception_equipments_dialog"));
				});
				$("#exception_equipments_dialog .sure_yes").unbind("click").click(function() {
					databind.submitDom($("#exception_equipments_dialog"), function() {
						base.alert(1, "异常情况添加成功！");
						dialog.hideDialog($("#exception_equipments_dialog"));
						router.route("exception/exceptionDetailInfo.html?abnormalId=" + abnormalId);
					});
				});
			} else if (exceptionBody == "exceptionBody7") {
				$("#popdialog").html(html_exception_expenses);
				$("#popdialog1").html(html_add_expenseName);
				tools.requireInput($("#popdialog"));
				dialog.showDialog($("#exception_expenses_dialog"));
				$("textarea").parent().css("text-align", "right");
				databind.fillForm($("#exception_expenses_dialog"), {
					"abnormalId": abnormalId
				});

				tools.inquireCommonSelectorList(9, $("#exception_expenses_dialog .expenseType"));
				$("#exception_expenses_dialog #addExpenseName").unbind("click").click(function() {
					dialog.showDialog($("#add_expenseName_dialog"));
					$("#add_expenseName_dialog .closeDiv").css("visibility", "hidden");
					databind.fillInput($("#add_expenseName_dialog"), {
						action: "inquireSystemParam.json?paramId=9"
					});
					$("#add_expenseName_dialog .sure_no").unbind("click").click(function() {
						dialog.hideSelfDialog($("#add_expenseName_dialog"));
					});

					$("#add_expenseName_dialog .sure_yes").unbind("click").click(function() {
						var p = $.trim($("#newExpenseName").val());
						if (p != "") {
							$("#add_expenseName_dialog .paramValue").val($("#add_expenseName_dialog .paramValue").val() + ',' + p);
							databind.submitDom($("#add_expenseName_dialog"), function() {
								base.alert(1, "费用名称添加成功！");
								dialog.hideSelfDialog($("#add_expenseName_dialog"));
								tools.inquireCommonSelectorList(9, $("#exception_expenses_dialog .expenseType"));
							});
						}
					});
				});

				$("#exception_expenses_dialog").on("change", ".mold1", function() {
					judgeMold($(this).val(), $("#disbursementName"), $("#disbursementId"));
				});

				$("#exception_expenses_dialog").on("change", ".mold2", function() {
					judgeMold($(this).val(), $("#receiptName"), $("#receiptId"));
				});

				$("#exception_expenses_dialog .sure_no").unbind("click").click(function() {
					dialog.hideDialog($("#exception_expenses_dialog"));
				});
				$("#exception_expenses_dialog .sure_yes").unbind("click").click(function() {
					databind.submitDom($("#exception_expenses_dialog"), function() {
						base.alert(1, "异常费用添加成功！");
						dialog.hideDialog($("#exception_expenses_dialog"));
						router.route("exception/exceptionDetailInfo.html?abnormalId=" + abnormalId);
					});
				});
			}
		});

	};

	//接受融资异常信息
	var confirmException = function() {
		base.fnAjax({
			action: "confirmAbnormal.json",
			oData: {
				abnormalId: abnormalId
			}, //传递参数
			fnSuccess: function(data) {
				if (data.status == 200) {
					base.alert(1, "异常信息接受成功！");
					router.route("exception/exceptionDetailInfo.html?abnormalId=" + abnormalId);
				} else {
					base.alert(2, "信息获取失败");
				}
			}
		});
	};

	//退货处理
	var returnAbnormalInventory = function(abnormalInventoryId) {
		base.fnAjax({
			action: "returnAbnormalInventory.json",
			oData: {
				abnormalInventoryId: abnormalInventoryId
			}, //传递参数
			fnSuccess: function(data) {
				if (data.status == 200) {
					base.alert(1, "退货成功！");
					router.route("exception/exceptionDetailInfo.html?abnormalId=" + abnormalId);
				} else {
					base.alert(2, "信息获取失败");
				}
			}
		});
	};


	//编辑融资异常信息
	var editException = function() {
		$("#updateException").removeClass("none");
		$("#processException").removeClass("none");
	};

	//修改融资异常信息
	var updateException = function() {
		databind.submitDom($(".exceptionDetailInfoContent"), function() {
			base.alert(1, "异常信息保存成功!");
			router.route("exception/exceptionDetailInfo.html?abnormalId=" + abnormalId);
		});
	};

	//处理融资异常信息
	var processException = function() {
		base.fnAjax({
			action: "processAbnormal.json",
			oData: {
				abnormalId: abnormalId
			}, //传递参数
			fnSuccess: function(data) {
				if (data.status == 200) {
					base.alert(1, "异常信息处理成功！");
					router.route("exception/exceptionDetailInfo.html?abnormalId=" + abnormalId);
				} else {
					base.alert(2, "信息获取失败");
				}
			}
		});
	};

	//关闭融资异常信息
	var finishException = function() {
		base.fnAjax({
			action: "finishAbnormal.json",
			oData: {
				abnormalId: abnormalId
			}, //传递参数
			fnSuccess: function(data) {
				if (data.status == 200) {
					base.alert(1, "异常信息关闭成功！");
					router.route("exception/exceptionDetailInfo.html?abnormalId=" + abnormalId);
				} else {
					base.alert(2, "信息获取失败");
				}
			}
		});
	};

	//查询异常信息明细
	var inquireAbnormalDetail1 = function() {
		base.fnAjax({
			action: "inquireAbnormalDetail.json",
			async: false,
			oData: {
				abnormalId: abnormalId
			}, //传递参数
			fnSuccess: function(data) {
				if (data.status == 200) {
					juicer.register("getValueByKey", constant.getValueByKey);
					var tpl = $(".exceptionHtmlBulkstockTpl").html();
					var html = juicer(tpl, data);
					$(".exceptionHtmlBulkstockBody").html(html);
				} else {
					base.alert(2, "信息获取失败");
				}
			}
		});
	};

	//查询异常信息明细
	var consentAbnormalExpense = function(abnormalExpenseId) {
		base.fnAjax({
			action: "consentAbnormalExpense.json",
			async: false,
			oData: {
				abnormalExpenseId: abnormalExpenseId
			}, //传递参数
			fnSuccess: function(data) {
				if (data.status == 200) {
					base.alert(1, "确认异常费用成功！");
					router.route("exception/exceptionDetailInfo.html?abnormalId=" + abnormalId);
				} else {
					base.alert(2, data.message);
				}
			}
		});
	};

	//查询异常信息列表
	var inquireAbnormalDetail = function() {
		base.fnAjax({
			action: "inquireAbnormalDetail.json",
			oData: {
				abnormalId: abnormalId
			}, //传递参数
			fnSuccess: function(data) {
				if (data.status == 200) {
					juicer.register("getValueByKey", constant.getValueByKey);
					databind.fillForm($("#exceptionDetailInfo"), data.datas[0]);
					handleState = data.datas[0].handleState;
					claimId = data.datas[0].claimId;

					if (handleState == 3) {
						$(".addException").removeClass("none");
					}

					if (data.datas[0].riskEnabled) {
						$(".riskInfo").removeClass("none");
						$(".riskEnabled").attr("checked", "true");
					}

					$(".exceptionRadio1").val(1);
					$(".exceptionRadio2").val(0);

					//					var riskTpl = $("#riskListTpl").html();
					//					var riskHtml = juicer(riskTpl, data);
					//					$("#riskListBody").html(riskHtml);
					//
					//<tr abnormalRiskId=${item.abnormalRiskId}>
					//									<td><select class="riskType" value="${item.riskType}" ></select></td>	
					//									<td>${item.riskName}</td>
					//									<td>${item.description}</td>	
					//									<td><select class="strategy" value="${item.strategy}"></select></td>
					//									<td><select class="riskGrade" value="${item.riskGrade}"></select></td>
					//									<td>${item.distinguish}</td>
					//									<td>${item.distinguishDate}</td>
					//									</tr>
					var abnormalRisks = data.datas[0].abnormalRisks;
					var str;
					inquireCommonSelectorList(12);
					var riskTypeList = commonSelectorList;
					inquireCommonSelectorList(13);
					var strategyList = commonSelectorList;
					inquireCommonSelectorList(14);
					var riskGradeList = commonSelectorList;
					$.each(abnormalRisks, function(i, val) {
						var riskTypeText = "";
						var strategyeText = "";
						var riskGradeText = "";
						$.each(riskTypeList.datas, function(i, riskTypes) {
							if (val.riskType == riskTypes.index) {
								riskTypeText = riskTypes.reson;
							}
						});
						$.each(strategyList.datas, function(i, strategys) {
							if (val.strategy == strategys.index) {
								strategyeText = strategys.reson;
							}
						});
						$.each(riskGradeList.datas, function(i, riskGrades) {
							if (val.riskGrade == riskGrades.index) {
								riskGradeText = riskGrades.reson;
							}
						});
						str += '<tr abnormalRiskId=' + val.abnormalRiskId + '>';
						str += '				<td>' + riskTypeText + ' </td>	';
						str += '				<td>' + val.riskName + '</td>';
						str += '				<td>' + val.description + '</td>	';
						str += '				<td>' + strategyeText + '</td>';
						str += '				<td>' + riskGradeText + '</td>';
						str += '				<td>' + val.distinguish + '</td>';
						str += '				<td>' + val.distinguishDate + '</td>';
						str += '	<td><a href="javascript:void(0)" class="riskDetail">详情</a></td>';
						str += '		</tr>';
					});
					$("#riskListBody").html(str);
					//					tools.inquireCommonSelectorList(12, $(".riskType"));
					//				tools.inquireCommonSelectorList(13, $(".strategy"));
					//				tools.inquireCommonSelectorList(14, $(".riskGrade"));

					var tpl = $("#exceptionDetailBulkstockTpl").html();
					var html = juicer(tpl, data);
					$("#exceptionDetailBulkstockBody").html(html);

					var tpl_1 = $("#exceptionTpl_1").html();
					var html_1 = juicer(tpl_1, data);
					$("#exceptionBody_1").html(html_1);

					if ($.trim($("#abnormalImages").val()) == "") {

					} else {
						var images = $("#abnormalImages").val().split(',');
						$.each(images, function() {
							$("#abnormalImages").parent().append("<a fileUuid='" + this + "' href='/finance/api/v1.0/downloadFile.file?fileUuid=" + this + "' target='_blank'>查看</a> ");
						});
					}

					if ($.trim($("#signAbnormalFile").val()) == "") {

					} else {
						var images = $("#signAbnormalFile").val().split(',');
						$.each(images, function() {
							$("#signAbnormalFile").parent().append("<a fileUuid='" + this + "' href='/finance/api/v1.0/downloadFile.file?fileUuid=" + this + "' target='_blank'>查看</a> ");
						});
					}

					$("#abnormalImages").parent().find("a").mouseover(function(e) {
						$("#showImage").css({
							"display": "block",
							"background": "url(/finance/api/v1.0/downloadFile.file?fileUuid=" + $(this).attr('fileUuid') + ") no-repeat #CCC",
							"background-position": "center"
						});
					});

					$("html").click(function() {
						$("#showImage").css({
							"display": "none",
							"background": "none"
						});
					});

					$(".exceptionInventoryDetail").unbind("click").click(function() {
						router.route("account/accountTallyDetail.html?inventoryId=" + $(this).parents("tr").attr("inventoryId"));
					});

					if (claimId == 0) {
						$("#inquireClaim").remove();
					} else {
						$("#createClaim").remove();
					}

					$("#inquireInsurance").remove();

					$("#exceptionDetailInfo").on("click", "#inquireClaim", function() {
						router.route("claimManage/claimManage.html");
					});

					$("#confirmException").unbind("click").click(function() {
						confirmException();
					});

					$("#processException").unbind("click").click(function() {
						processException();
					});

					$("#finishException").unbind("click").click(function() {
						finishException();
					});

					$(".abnormalExpenseConsent").unbind("click").click(function() {
						var aei = $(this).parents("tr").attr("abnormalExpenseId");
						dialog.showConfirmDialog("异常费用确认", "是否要确认该异常费用？", function() {
							consentAbnormalExpense(aei);
						});
					});

					//异常调查详情
					$("#exceptionDetailInfo").on("click", ".exceptionBody1 .detail", function() {
						var abnormalSurveyId = $(this).parents("tr").attr("abnormalSurveyId");
						showSurveysDetail(abnormalSurveyId);
					});

					//异常调查确认
					$("#exceptionDetailInfo").on("click", ".exceptionBody1 .consentAbnormalSurvey", function() {
						var abnormalSurveyId = $(this).parents("tr").attr("abnormalSurveyId");
						dialog.showConfirmDialog("异常调查确认", "是否要确认该异常调查？", function() {
							consentAbnormalSurvey(abnormalSurveyId);
						});
					});

					//责任人处理详情
					$("#exceptionDetailInfo").on("click", ".exceptionBody2 .detail", function() {
						var abnormalBlameId = $(this).parents("tr").attr("abnormalBlameId");
						showBlamesDetail(abnormalBlameId);
					});

					//责任人处理确认
					$("#exceptionDetailInfo").on("click", ".exceptionBody2 .consentAbnormalBlame", function() {
						var abnormalBlameId = $(this).parents("tr").attr("abnormalBlameId");
						dialog.showConfirmDialog("责任人处理确认", "确定要确认此责任人处理吗", function() {
							consentAbnormalBlame(abnormalBlameId);
						});
					});

					//整改总结详情
					$("#exceptionDetailInfo").on("click", ".exceptionBody3 .detail", function() {
						var abnormalCorrectiveId = $(this).parents("tr").attr("abnormalCorrectiveId");
						showCorrectivesDetail(abnormalCorrectiveId);
					});
					//整改总结确认
					$("#exceptionDetailInfo").on("click", ".exceptionBody3 .consentAbnormalCorrective", function() {
						var abnormalCorrectiveId = $(this).parents("tr").attr("abnormalCorrectiveId");
						dialog.showConfirmDialog("整改总结确认", "确定要确认此整改总结吗", function() {
							consentAbnormalCorrective(abnormalCorrectiveId);
						});
					});

					//人员伤亡详情
					$("#exceptionDetailInfo").on("click", ".exceptionBody4 .detail", function() {
						var abnormalCasualtyId = $(this).parents("tr").attr("abnormalCasualtyId");
						showCasualtiesDetail(abnormalCasualtyId);
					});

					//人员伤亡确认
					$("#exceptionDetailInfo").on("click", ".exceptionBody4 .consentAbnormalCasualty", function() {
						var abnormalCasualtyId = $(this).parents("tr").attr("abnormalCasualtyId");
						dialog.showConfirmDialog("人员伤亡确认", "确定要确认此人员伤亡吗", function() {
							consentAbnormalCasualty(abnormalCasualtyId);
						});


					});

					//异常情况详情
					$("#exceptionDetailInfo").on("click", ".exceptionBody5 .detail", function() {
						var abnormalEquipmentId = $(this).parents("tr").attr("abnormalEquipmentId");
						showEquipmentsDetail(abnormalEquipmentId);
					});

					//异常情况确认
					$("#exceptionDetailInfo").on("click", ".exceptionBody5 .consentAbnormalEquipment", function() {
						var abnormalEquipmentId = $(this).parents("tr").attr("abnormalEquipmentId");
						dialog.showConfirmDialog("异常情况确认", "确定要确认此异常情况吗", function() {
							consentAbnormalEquipment(abnormalEquipmentId);
						});


					});
					//异常情况详情
					$("#exceptionDetailInfo").on("click", ".exceptionBody6 .detail", function() {
						var abnormalSource = $(this).parents("tr").attr("abnormalSource");
						var abnormalSourceId = $(this).parents("tr").attr("abnormalSourceId");
						showTracksDetail(abnormalSource, abnormalSourceId);
					});

					//异常费用详情
					$("#exceptionDetailInfo").on("click", ".exceptionBody7 .detail", function() {
						var abnormalExpenseId = $(this).parents("tr").attr("abnormalExpenseId");
						showExpenseDetail(abnormalExpenseId);
					});

					if (handleState != 3) {
						$(".addException").addClass("none");
					} else {
						if ($(this).attr("exceptionBody") == "exceptionBody6") {
							$(".addException").addClass("none");
						} else {
							$(".addException").removeClass("none");
						}
					}

					//风险详情
					$(".riskDetail").unbind("click").click(function() {
						var abnormalRiskId = $(this).parent().parent("tr").attr("abnormalRiskId");
						inquireAbnormalRiskDetail(abnormalRiskId);

					});
					//是否标识为风险
					$(".riskEnabled").on("change", function() {
						var d = $(this);
						if (d.prop("checked")) {
							d.parents(".exceptionDetailInfoContent").find(".riskInfo").removeClass("none");
						} else {
							d.parents(".exceptionDetailInfoContent").find(".riskInfo").addClass("none");
						}
					});
					databind.disableInput($("#exceptionDetailInfo"));

				} else {
					base.alert(3, "信息获取失败");
				}
			}
		});
	};

	var showExpenseDetail = function(abnormalExpenseId) {
		$("#popdialog").html(html_exception_expenses);
		$("#addExpenseName").remove();
		tools.inquireCommonSelectorList(9, $("#exception_expenses_dialog .expenseType"));
		dialog.showDialog($("#exception_expenses_dialog"));
		databind.fillInput($("#exception_expenses_dialog"), {
			action: "inquireAbnormalExpenseDetail.json?abnormalExpenseId=" + abnormalExpenseId
		});
		databind.disableInput($("#exception_expenses_dialog"));
		$("#exception_expenses_dialog .sure_no").hide();
		$("#exception_expenses_dialog").on("click", ".sure_yes", function() {
			dialog.hideDialog($("#exception_expenses_dialog"));
		});
	};

	var showEquipmentsDetail = function(abnormalEquipmentId) {
		$("#popdialog").html(html_exception_equipments);
		dialog.showDialog($("#exception_equipments_dialog"));
		databind.fillInput($("#exception_equipments_dialog"), {
			action: "inquireAbnormalEquipmentDetail.json?abnormalEquipmentId=" + abnormalEquipmentId
		});
		databind.disableInput($("#exception_equipments_dialog"));
		$("#exception_equipments_dialog .sure_no").hide();
		$("#exception_equipments_dialog").on("click", ".sure_yes", function() {
			dialog.hideDialog($("#exception_equipments_dialog"));
		});
	};

	var showCasualtiesDetail = function(abnormalCasualtyId) {
		$("#popdialog").html(html_exception_casualties);
		dialog.showDialog($("#exception_casualties_dialog"));
		databind.fillInput($("#exception_casualties_dialog"), {
			action: "inquireAbnormalCasualtyDetail.json?abnormalCasualtyId=" + abnormalCasualtyId
		});
		databind.disableInput($("#exception_casualties_dialog"));
		$("#exception_casualties_dialog .sure_no").hide();
		$("#exception_casualties_dialog").on("click", ".sure_yes", function() {
			dialog.hideDialog($("#exception_casualties_dialog"));
		});
	};

	var showCorrectivesDetail = function(abnormalCorrectiveId) {
		$("#popdialog").html(html_exception_correctives);
		dialog.showDialog($("#exception_correctives_dialog"));
		databind.fillInput($("#exception_correctives_dialog"), {
			action: "inquireAbnormalCorrectiveDetail.json?abnormalCorrectiveId=" + abnormalCorrectiveId
		});
		databind.disableInput($("#exception_correctives_dialog"));
		$("#exception_correctives_dialog .sure_no").hide();
		$("#exception_correctives_dialog").on("click", ".sure_yes", function() {
			dialog.hideDialog($("#exception_correctives_dialog"));
		});
	};

	var showBlamesDetail = function(abnormalBlameId) {
		$("#popdialog").html(html_exception_blames);
		dialog.showDialog($("#exception_blames_dialog"));
		databind.fillInput($("#exception_blames_dialog"), {
			action: "inquireAbnormalBlameDetail.json?abnormalBlameId=" + abnormalBlameId
		});
		databind.disableInput($("#exception_blames_dialog"));
		$("#exception_blames_dialog .sure_no").hide();
		$("#exception_blames_dialog").on("click", ".sure_yes", function() {
			dialog.hideDialog($("#exception_blames_dialog"));
		});
	};

	var showSurveysDetail = function(abnormalSurveyId) {
		$("#popdialog").html(html_exception_surveys);
		dialog.showDialog($("#exception_surveys_dialog"));
		databind.fillInput($("#exception_surveys_dialog"), {
			action: "inquireAbnormalSurveyDetail.json?abnormalSurveyId=" + abnormalSurveyId
		});
		databind.disableInput($("#exception_surveys_dialog"));
		$("#exception_surveys_dialog .sure_no").hide();
		$("#exception_surveys_dialog").on("click", ".sure_yes", function() {
			dialog.hideDialog($("#exception_surveys_dialog"));
		});
	};

	var showTracksDetail = function(abnormalSource, abnormalSourceId) {
		if (abnormalSource == 1) {
			showBlamesDetail(abnormalSourceId);
		} else if (abnormalSource == 2) {
			showCasualtiesDetail(abnormalSourceId);
		} else if (abnormalSource == 3) {
			showEquipmentsDetail(abnormalSourceId);
		} else if (abnormalSource == 4) {
			showSurveysDetail(abnormalSourceId);
		} else if (abnormalSource == 5) {
			showCorrectivesDetail(abnormalSourceId);
		}
	};
	//确认责任人处置
	var consentAbnormalBlame = function(abnormalBlameId) {
		base.fnAjax({
			action: "consentAbnormalBlame.json",
			oData: {
				abnormalBlameId: abnormalBlameId
			}, //传递参数
			fnSuccess: function(data) {
				if (data.status == 200) {
					base.alert(1, "确认责任人处置成功！");
					router.route("exception/exceptionDetailInfo.html?abnormalId=" + abnormalId);
				} else {
					base.alert(3, data.message);
				}
			}
		});
	}

	//确认人员伤亡
	var consentAbnormalCasualty = function(abnormalCasualtyId) {
			base.fnAjax({
				action: "consentAbnormalCasualty.json",
				oData: {
					abnormalCasualtyId: abnormalCasualtyId
				}, //传递参数
				fnSuccess: function(data) {
					if (data.status == 200) {
						base.alert(1, "确认人员伤亡成功！");
						router.route("exception/exceptionDetailInfo.html?abnormalId=" + abnormalId);
					} else {
						base.alert(3, data.message);
					}
				}
			});
		}
		//确认设备损坏
	var consentAbnormalEquipment = function(abnormalEquipmentId) {
			base.fnAjax({
				action: "consentAbnormalEquipment.json",
				oData: {
					abnormalEquipmentId: abnormalEquipmentId
				}, //传递参数
				fnSuccess: function(data) {
					if (data.status == 200) {
						base.alert(1, "确认设备损坏成功！");
						router.route("exception/exceptionDetailInfo.html?abnormalId=" + abnormalId);
					} else {
						base.alert(3, data.message);
					}
				}
			});
		}
		//确认异常调查
	var consentAbnormalSurvey = function(abnormalSurveyId) {
		base.fnAjax({
			action: "consentAbnormalSurvey.json",
			oData: {
				abnormalSurveyId: abnormalSurveyId
			}, //传递参数
			fnSuccess: function(data) {
				if (data.status == 200) {
					base.alert(1, "确认异常调查成功！");
					router.route("exception/exceptionDetailInfo.html?abnormalId=" + abnormalId);
				} else {
					base.alert(3, data.message);
				}
			}
		});
	}

	//整改总结确认
	var consentAbnormalCorrective = function(abnormalCorrectiveId) {
		base.fnAjax({
			action: "consentAbnormalCorrective.json",
			oData: {
				abnormalCorrectiveId: abnormalCorrectiveId
			}, //传递参数
			fnSuccess: function(data) {
				if (data.status == 200) {
					base.alert(1, "确认整改总结成功！");
					router.route("exception/exceptionDetailInfo.html?abnormalId=" + abnormalId);
				} else {
					base.alert(3, data.message);
				}
			}
		});
	}

	//上传文件
	var uploadFile = function(dom, labelDom, valueDom, fileElementId) {
		if ($(dom).val() != "") {
			$.ajaxFileUpload({
				url: "/finance/api/v1.0/uploadFile.json", //你处理上传文件的服务端
				secureuri: false,
				fileElementId: "claimMaterial",
				dataType: 'json',
				success: function(data) {
					$(valueDom).val(data.data[0].fileUuid);
					$(labelDom).html(data.data[0].fileName);
				},
				complete: function(xml) {
					$(dom).change(function() {
						uploadFile(dom, labelDom, fileElementId);
					});
				},
				error: function(data, status, e) {
					if (data.msg == null) {
						base.alert(2, "文件太大无法上传");
					} else {
						base.alert(2, data.msg);
					}
				}
			});
		} else {
			base.alert(3, "请选择文件！");
		}
	};
	//查询常规原因
	var inquireCommonSelectorList = function(resonType) {
		base.fnAjax({
			action: "inquireCommonSelectorList.json",
			async: false,
			oData: {
				resonType: resonType
			}, //传递参数
			fnSuccess: function(data) {
				if (data.status == 200) {
					commonSelectorList = data;

				} else {
					base.alert(3, "信息获取失败");
				}
			}
		});
	}

	//常规选项
	var inquireCommonSelectorList1 = function(resonType, dom) {
		base.fnAjax({
			action: "inquireCommonSelectorList.json",
			async: false,
			oData: {
				resonType: resonType
			}, //传递参数
			fnSuccess: function(data) {
				if (data.status == 200) {
					//					$(dom).html("");
					$.each(data.datas, function(i, v) {
						$(dom).append('<option value=' + this.index + '>' + this.reson + '</option>');
					});
				} else {
					base.alert(2, "信息获取失败");
				}
			}
		});
	};

	//风险信息明细
	var inquireAbnormalRiskDetail = function(abnormalRiskId) {
		base.fnAjax({
			action: "inquireAbnormalRiskDetail.json",
			oData: {
				abnormalRiskId: abnormalRiskId
			}, //传递参数
			fnSuccess: function(data) {
				if (data.status == 200) {
					$("#popdialog").html(html_riskDetailInfo);
					tools.requireInput($("#popdialog"));
					dialog.showDialog($("#create_risk_dialog"));
					inquireCommonSelectorList1(12, $("#create_risk_dialog .riskType"));
					inquireCommonSelectorList1(13, $("#create_risk_dialog .strategy"));
					inquireCommonSelectorList1(14, $("#create_risk_dialog .riskGrade"));
					databind.fillForm($("#create_risk_dialog"), data.datas[0]);
					databind.disableInput($("#create_risk_dialog"));
//					$(".dialogHandlerBtn").remove();
					$("#create_risk_dialog .sure_yes").unbind("click").click(function(){
						dialog.hideDialog($("#create_risk_dialog"));
					});

					$(".claimMaterial").remove();

					$(".riskFileUuid").html('<a target="_blank" href="/finance/api/v1.0/downloadFile.file?fileUuid=' + $("#riskFileUuid").val() + '"><img src="../../../res/png/contract1.png"></a>');
				} else {
					base.alert(3, "信息获取失败");
				}
			}
		});
	};

	//物流公司自动补全
	var logisticsAutoComplete = function(dom, dom1) {
		//自动补全
		$(dom).autocomplete(seajs.data.handler + "inquireLogisticsCompanyList.json", {
			minChars: 1,
			max: 10,
			width: 120,
			matchCase: false, //不区分大小写
			scroll: true,
			dataType: 'json',
			scrollHeight: 500,
			//此处为传递而外的参数
			extraParams: {
				pageSize: 1000,
				appKey: base.getData("appKey"),
				sessionUuid: base.getData("sid"),
				companyName: function() {
					return $(dom).val();
				}
			},
			//需要把data转换成json数据格式                      
			parse: function(data) {
				return $.map(eval(data.datas), function(row) {
					return {
						data: row,
						value: row.companyName, //此处无需把全部列列出来，只是两个关键列
						result: row.companyName
					}
				});
			},
			formatItem: function(data, i, total) {
				if ($(dom).hasClass('nonemorelist')) {
					$(dom).removeClass('nonemorelist');
					return;
				};
				return "<table><tr><td>" + data.companyName + "</td></tr></table>";
			},
			formatMatch: function(data, i, total) {
				return data.companyName;
			},
			formatResult: function(data, value) {
				return data.companyName;
			}
		}).result(function(event, data, formatted) { //回调
			$('#chargecategoryName').val(data.companyName);
			if ($(dom).hasClass('nonemorelist')) {
				$(dom).removeClass('nonemorelist');
			} else {
				$(dom).addClass('nonemorelist');
			};
			$(dom1).val(data.companyId);
			autoComplete(data.companyId);
		});
	};

	//企业自动补全
	var enterpriseAutoComplete = function(dom, dom1) {
		//自动补全
		$(dom).autocomplete(seajs.data.handler + "inquireEnterprisePageList.json", {
			minChars: 1,
			max: 10,
			width: 120,
			matchCase: false, //不区分大小写
			scroll: true,
			dataType: 'json',
			scrollHeight: 500,
			//此处为传递而外的参数
			extraParams: {
				pageSize: 1000,
				appKey: base.getData("appKey"),
				sessionUuid: base.getData("sid"),
				enterpriseName: function() {
					return $(dom).val();
				}
			},
			//需要把data转换成json数据格式                      
			parse: function(data) {
				return $.map(eval(data.datas), function(row) {
					return {
						data: row,
						value: row.enterpriseName, //此处无需把全部列列出来，只是两个关键列
						result: row.enterpriseName
					}
				});
			},
			formatItem: function(data, i, total) {
				if ($(dom).hasClass('nonemorelist')) {
					$(dom).removeClass('nonemorelist');
					return;
				};
				return "<table><tr><td>" + data.enterpriseName + "</td></tr></table>";
			},
			formatMatch: function(data, i, total) {
				return data.enterpriseName;
			},
			formatResult: function(data, value) {
				return data.enterpriseName;
			}
		}).result(function(event, data, formatted) { //回调
			$(dom).val(data.categoryName);
			if ($(dom).hasClass('nonemorelist')) {
				$(dom).removeClass('nonemorelist');
			} else {
				$(dom).addClass('nonemorelist');
			};
			$(dom1).val(data.enterpriseId);
			autoComplete(data.enterpriseId);
		});
	};

	var judgeMold = function(type, company, companyId) {
		type = parseInt(type);
		switch (type) {
			case 1:
				$(company).val("平台");
				$(companyId).val("");
				$(company).attr("readonly", "readonly");
				break;
			case 2:
				$(company).val("");
				$(company).removeAttr("readonly");
				$(companyId).val("");
				logisticsAutoComplete($(company), $(companyId));
				break;
			case 3:
				$(company).removeAttr("readonly");
				$(company).val("");
				$(companyId).val("");
				enterpriseAutoComplete($(company), $(companyId));
				break;
			case 4:
				$(company).removeAttr("readonly");
				$(company).val("");
				$(companyId).val("");
				$(company).val("");
				break;
			default:
				break;
		}
	}
	return {
		init: init
	};
});